package com.shy;

import com.shy.autoconofig.EnableOSConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;

@SpringBootApplication
@EnableOSConfig
public class ShySpringBootApplication implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(ShySpringBootApplication.class, args);
    }

    @Autowired
    private ApplicationContext context;

    @Override
    public void run(String... args) throws Exception {
        System.out.println(context.getBean("os"));
        System.out.println(context.getId());
        context.publishEvent(new ApplicationEvent("myEvent") {
        });

        int a = 1 / 0;
    }
}